 window.onload = function() {  
    init();  //初始化  
}
 function init() {  
	    //初始化文档上传  
	    var btnFile = document.getElementById("btnUploadFile");  
	    var btnXP = document.getElementById("userXP");
	    if( btnFile != null){
	    	 g_AjxUploadFile(btnFile);  
	    }
	    
	   if( btnXP != null ){
		   g_AjxUploadUserImg(btnXP);
	   }
	   
		
	      
	}  
 
 function g_AjxUploadFile(btn) {  
	    var button = btn, interval;  
	    new AjaxUpload(button, {  
	    action: "UploadUserFile.action",  
	        data: {},  
	        name: 'file',  
	        onSubmit: function(file, ext) {  
	            if (!(ext && /^(rar|zip|pdf|pdfx|txt|csv|xls|xlsx|doc|docx|RAR|ZIP|PDF|PDFX|TXT|CSV|XLS|XLSX|DOC|DOCX)$/.test(ext))) {  
	                alert("您上传的文档格式不对，请重新选择！");  
	                return false;  
	            }  
	        },  
	        onComplete: function(file, response) {  
	            flagValue = response;  
	            if (flagValue == 1) {  
	                alert("您上传的文档格式不对，请重新选择！");  
	            }  
	            else if (flagValue == 2) {  
	                alert("您上传的文档大于2M，请重新选择！");  
	            }  
	            else if (flagValue == 3) {  
	                alert("文档上传失败！");  
	            }  
	            else {  
		             alert("上传成功");
		             onsuccess = function(){
							var i = parseInt(scope.tempAccountList.length / 10);
							if(  scope.tempAccountList.length % 10 == 0 ){
								scope.pageAccountManagement(i);
							}
							else{
								scope.pageAccountManagement(i+1);
							}
						}
						scope.accountManagement(onsuccess);
	            }  
	        }  
	    });  
	} ;
	
	 function g_AjxUploadUserImg(btn) {  
		    var button = btn, interval;  
		    
		    new AjaxUpload(button, {  
		    action: "UploadUserImg.action",  
		        data: {},  
		        name: 'file',  
		        onSubmit: function(file, ext) {
		        	if (!(ext && /^(jpg|JPG|png|PNG|gif|GIF)$/.test(ext))) {  
		                alert("您上传的图片格式不对，请重新选择！");  
		                return false;  
		            } 
		        },  
		        onComplete: function(file, response) {  
		            flagValue = response;  
		            if (flagValue == 1) {  
		                alert("您上传的图片格式不对，请重新选择！");  
		            }  
		            else if (flagValue == 2) {  
		                alert("您上传的图片大于2M，请重新选择！");  
		            }  
		            else if (flagValue == 3) {  
		                alert("图片上传失败！");  
		            }  
		            else {  
		            	console.log(flagValue);
		            	scope.$apply(function() {
		            		scope.temp.userXP = flagValue;
		            	  });		            	
			             alert("上传成功");
			           
		            }  
		        }  
		    });  
		}  